home *** CD-ROM | disk | FTP | other *** search
- Path: news.crd.ge.com!rebecca!news
- From: Helin Wei <whl@climate.asrc.albany.edu>
- Newsgroups: comp.lang.c++
- Subject: help need in rewriting the code from c to c++
- Date: Sun, 14 Apr 1996 21:17:56 -0400
- Organization: The University at Albany
- Message-ID: <3171A3C3.799@climate.asrc.albany.edu>
- NNTP-Posting-Host: csss1.climate.asrc.albany.edu
- Mime-Version: 1.0
- Content-Type: multipart/mixed; boundary="------------C5C411870FA"
- X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.4 sun4c)
-
- This is a multi-part message in MIME format.
-
- --------------C5C411870FA
- Content-Type: text/plain; charset=gb2312
- Content-Transfer-Encoding: 7bit
-
- Anyone can help me rewrite the following code in c++,I'd appreciate
- if he can mail the result to whl@climate.asrc.albany.edu.Thanks.
-
- --------------C5C411870FA
- Content-Type: text/plain; charset=gb2312
- Content-Transfer-Encoding: 7bit
- Content-Disposition: inline; filename="signal.c"
-
- /*--------------------------------------------------------------------*/
-
- #ifdef sun
-
- #include <signal.h>
- #include <stdio.h>
- #define SUN
-
- void stopgf_();
-
- void setsig_()
- { /* set up to catch a few signals */
-
- #include <floatingpoint.h>
- void sgsegv(), sgbuserr();
- void sginexact(), sg0div(), sgunder(), sgover(), sginvalid();
- struct sigvec sigsegv, sigbus;
- extern int sigvec(), ieee_handler();
-
- sigsegv.sv_handler = sgsegv;
- sigbus.sv_handler = sgbuserr;
- (void) sigvec(SIGSEGV, &sigsegv, NULL);
- (void) sigvec(SIGBUS, &sigbus, NULL);
- /*ieee_handler("set", "inexact", sginexact);*/
- ieee_handler("set", "division", sg0div);
- ieee_handler("set", "underflow", sgunder);
- ieee_handler("set", "overflow", sgover);
- ieee_handler("set", "invalid", sginvalid);
-
- return;
- }
-
-
- /* Signal handlers follow */
-
-
- void sgsegv()
- {
- printf("Segmentation violation");
- stopgf_();
- }
-
-
- void sgbuserr()
- {
- printf("Bus error");
- stopgf_();
- }
-
-
- void sginexact()
- {
- printf("Inexact FPE error");
- stopgf_();
- }
-
-
- void sg0div()
- {
- printf("Division by zero FPE error");
- stopgf_();
- }
-
-
- void sgunder()
- {
- printf("Underflow FPE error");
- stopgf_();
- }
-
-
- void sgover()
- {
- printf("Overflow FPE error");
- stopgf_();
- }
-
-
- void sginvalid()
- {
- printf("Invalid FPE error");
- stopgf_();
- }
-
-
- void stopgf_()
- {
- printf("\nstopgf_() called\n");
- abort();
- }
-
- #endif
-
- /*--------------------------------------------------------------------*/
-
- #ifdef sgi
-
- void setsig_()
- {
- }
-
- #endif
-
- /*--------------------------------------------------------------------*/
-
- #ifdef cray
-
- void SETSIG()
- {
- }
-
- #endif
-
- /*--------------------------------------------------------------------*/
-
- --------------C5C411870FA--
-
-